 $(document).ready(function () {
            var icon = "<i class='fa fa-times-circle'></i>";
            var form = $('form.js-ajax-forms');
            var formloading = false;
            form.validate({
                //验证规则
                rules: {
                    ContractName: {
                        required: true
                    },
                    Bill:{
                        required: true
                    },
                    UserName: {
                        required: true
                    },
                    DepName: {
                        required: true
                    }
                },
                //验证未通过提示消息
                messages: {
                    ContractName:{
                        required: icon + "请输入合同名称"
                    },
                    Bill :{
                        required: icon + "输入支付金额"
                    },
                    UserName:{
                        required: icon + "请输入起草人"
                    },
                    DepName:{
                        required: icon + "请输入起草部门"
                    }
                },
                //验证通过，提交表单
                submitHandler : function(forms) {
                    if (formloading)
                    return;
                    $(forms).ajaxSubmit({
                        url : form.attr('action'), //按钮上是否自定义提交地址(多按钮情况)
                        dataType : 'json',
                        beforeSubmit : function(arr, $form, options) {
                            formloading = true;
                        },
                        success : function(data, statusText, xhr, $form) {
                            formloading = false;
                            if (data.status) {
                                //添加成功
                                swal({
                                    title: "继续操作？",
                                    text: "操作成功！",
                                    type: "success",
                                    showCancelButton: true,
                                    confirmButtonColor: "#DD6B55",
                                    confirmButtonText: "确认",
                                    cancelButtonText: "返回",
                                    closeOnConfirm: false,
                                    closeOnCancel: false
                                },
                                function (isConfirm) {
                                    if (isConfirm) {
                                        document.location.reload();
                                        //document.location.href = "/index.php?m=Admin&c=Contract&a=ContractBody&ContractID="+data.info.ID+"&ContractType="+data.info.ContractType;
                                    } else {
                                       // document.location.href = "{:U('Admin/Contract/ContractBody')}";
                                        return true;
                                    }
                                }); 
                            } else {
                                swal("操作失败", data.info, "error");
                            }
                        }
                    });
                }
            });
        });



    
    $('#ContractName').on('click', function(){
        layer.open({
            title:'录入与合同相关的单位',
            type: 2,
            area: ['800px', '500px'],
            fixed: false, //不固定
            maxmin: true,
            content: "/index.php?m=Admin&c=Contract&a=select"
        });
    });



 
  
